package com.qf.business.redevnlopes.core.listener;

import com.ken.event.action.apply.consumer.IKenEventHandler;
import com.ken.event.action.apply.consumer.KenEvent;
import com.ken.event.standard.entity.KenMessage;
import com.qf.business.redevnlopes.core.service.RedEnvelopesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

@KenEvent("rob-red")
@Slf4j
public class RedRobEventHandler implements IKenEventHandler<Map<String, Integer>> {

    @Autowired
    private RedEnvelopesService redEnvelopesService;

    @Override
    public void eventHandler(Map<String, Integer> map, KenMessage kenMessage) {
        log.debug("[rob red event] 接收到抢红包的事件 - {}", map);
        Integer redid = map.get("redid");
        Integer uid = map.get("uid");
        Integer robScore = map.get("robScore");
        redEnvelopesService.robRed(redid, uid, robScore);
    }
}